package vip.liux.contracts.repositories.coupon;

import jakarta.validation.constraints.NotNull;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.ListCrudRepository;
import org.springframework.data.repository.ListPagingAndSortingRepository;
import org.springframework.data.repository.NoRepositoryBean;
import vip.liux.contracts.models.coupon.Coupon;
import vip.liux.contracts.shared.enums.Status;
import vip.liux.contracts.shared.enums.coupon.CouponType;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

@NoRepositoryBean
public interface CouponRepository extends ListPagingAndSortingRepository<Coupon, Long>, ListCrudRepository<Coupon, Long> {

    List<Coupon> findQueryAvailableCoupons();

    Optional<Coupon> findByCouponNo(String couponNo);

    Page<Coupon> findByPage(String couponName, CouponType couponType, Status status, @NotNull LocalDateTime receiveStart, @NotNull LocalDateTime receiveEnd, Pageable pageable);
}